home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / tagsgen.exe / SHELL.C < prev    next >
C/C++ Source or Header  |  1992-03-29  |  45KB  |  1,185 lines

  1. /*
  2.  EPSHeader
  3.  
  4.    File: tags.c
  5.    Author: J. Kercheval
  6.    Created: Sun, 03/31/1991  14:59:48
  7. */
  8. /*
  9.  EPSRevision History
  10.  
  11.    J. Kercheval  Sun, 03/31/1991  16:24:01  creation
  12.    J. Kercheval  Sun, 03/31/1991  16:43:18  allow @filename listfile syntax
  13.    J. Kercheval  Tue, 05/14/1991  19:46:50  add tag_type
  14.    J. Kercheval  Wed, 05/15/1991  18:19:22  add -m and -o parameters
  15.    J. Kercheval  Wed, 05/15/1991  19:23:42  correctly parse for logfile
  16.    J. Kercheval  Wed, 05/15/1991  22:22:33  add the sort module
  17.    J. Kercheval  Thu, 05/16/1991  22:47:04  move file IO to fileio.c
  18.    J. Kercheval  Wed, 06/26/1991  23:03:55  move back to standard IO
  19.    J. Kercheval  Thu, 06/27/1991  21:43:11  create tags.h
  20.    J. Kercheval  Fri, 07/12/1991  23:04:23  revise command line parsing
  21.    J. Kercheval  Sat, 07/13/1991  11:29:02  update Usage()
  22.    J. Kercheval  Sat, 07/13/1991  12:47:34  finish argf parsing
  23.    J. Kercheval  Sat, 07/13/1991  13:06:16  move input routines to input.c
  24.    J. Kercheval  Sun, 07/14/1991  19:18:36  finish DoTags
  25.    J. Kercheval  Wed, 07/17/1991  22:18:58  allow append file logging
  26.    J. Kercheval  Thu, 07/18/1991  18:53:31  use fully qualified input pathname
  27.    J. Kercheval  Fri, 07/19/1991  20:15:43  allow sort only and non-sort options
  28.    J. Kercheval  Sun, 07/21/1991  17:38:00  add post processing
  29.    J. Kercheval  Mon, 07/22/1991  17:35:08  tweak log output and interface
  30.    J. Kercheval  Sat, 07/27/1991  20:38:36  remove ASM public flag and post processing hooks
  31.    J. Kercheval  Sat, 08/17/1991  23:03:47  enable c tagging
  32.    J. Kercheval  Sun, 08/25/1991  22:49:55  fix bug in ASM flag parsing
  33.    J. Kercheval  Thu, 08/29/1991  23:30:47  add CRC checking for virus check
  34.    J. Kercheval  Sat, 08/31/1991  23:56:02  add prototype flag
  35.    J. Kercheval  Thu, 09/05/1991  01:29:13  add input file name tracking
  36.    J. Kercheval  Thu, 09/05/1991  01:29:42  add -t flag
  37.    J. Kercheval  Thu, 09/05/1991  02:01:28  finish tag output logic
  38.    J. Kercheval  Thu, 09/05/1991  20:07:45  move arglist processing to seperate module
  39.    J. Kercheval  Thu, 09/05/1991  20:13:50  move MergeFile() to tagio.c
  40.    J. Kercheval  Tue, 09/10/1991  23:24:27  add ctrl-c handler
  41.    J. Kercheval  Wed, 09/11/1991  01:45:35  add usage comments for extern switch
  42.    J. Kercheval  Tue, 09/17/1991  19:43:23  add support for case_sensitive flag
  43.    J. Kercheval  Wed, 09/25/1991  13:42:28  support sorted arglists
  44.    J. Kercheval  Wed, 09/25/1991  16:02:18  check for duplicate file names at the command line level
  45.    J. Kercheval  Wed, 09/25/1991  22:47:37  supress tag file merge if not input files found
  46.    J. Kercheval  Tue, 10/01/1991  19:30:26  close all open files in external_cleanup()
  47.    J. Kercheval  Thu, 10/03/1991  13:55:09  add exclude file processing
  48.    J. Kercheval  Thu, 10/03/1991  16:46:07  improve list file parsing
  49.    J. Kercheval  Sat, 10/05/1991  10:56:18  add switch summary to usage
  50. */
  51.  
  52. #include <stdlib.h>
  53. #include <stdio.h>
  54. #include <string.h>
  55. #include <time.h>
  56. #include <signal.h>
  57.  
  58. #include "flags.h"
  59. #include "log.h"
  60. #include "wildfile.h"
  61. #include "sort.h"
  62. #include "ctag.h"
  63. #include "asmtag.h"
  64. #include "tagio.h"
  65. #include "viruscrc.h"
  66. #include "arglist.h"
  67.  
  68.  
  69. #define Author "J. Kercheval"
  70. #define Version "Tags Generator V1.7"
  71. #define CompileDate __TIMESTAMP__
  72.  
  73.  
  74. /* The following variables are pointers to the temporary filenames used as
  75.  * an intermediary files.  These are globals for use in external_cleanup()
  76.  * to delete any temporary files. */
  77. char *tmp_filename = NULL;
  78. char *tmp_tagfilename = NULL;
  79.  
  80.  
  81. /*----------------------------------------------------------------------------
  82.  *
  83.  * Print Usage
  84.  *
  85.  ---------------------------------------------------------------------------*/
  86.  
  87. void Usage(char *fname)
  88. {
  89.  
  90.     fprintf(stdout, "\n%s %s -- %s\n\n", Version, CompileDate, Author);
  91.     fprintf(stdout, "Usage: %s {[OPTIONS] [SOURCEFILE|@LISTFILE]}\n\n",
  92.             fname);
  93.     fprintf(stdout, "  -h,-? for extended usage output to stdout\n");
  94.     fprintf(stdout, "  @LISTFILE for list file of input file names\n");
  95.     fprintf(stdout, "  -x{EXCLUDEFILE|@LISTFILE} to exclude files\n");
  96.     fprintf(stdout, "  -tTAGFILE to merge to a particular tag file\n");
  97.     fprintf(stdout, "  -lLOGFILE for log file (-l overwrites, -L appends)\n");
  98.     fprintf(stdout, "  -o[e5gsm] for output format\n");
  99.     fprintf(stdout, "  -a[fdlmsu] to specify assembly tagging\n");
  100.     fprintf(stdout, "  -c[dmstekuvcfpxi] to specify C tagging\n");
  101.     fprintf(stdout, "  -q will suppress normal status output\n");
  102.     fprintf(stdout, "  -r use relative pathnames in output\n");
  103.     fprintf(stdout, "  -n do not sort the tag output\n");
  104.     fprintf(stdout, "  -i use a case sensitive sort\n");
  105.     fprintf(stdout, "  -m for merge sort of the existing sorted files\n");
  106.     fprintf(stdout, "  -s sort input files only\n");
  107.     
  108.     exit(1);
  109. }
  110.  
  111.  
  112. /*----------------------------------------------------------------------------
  113.  *
  114.  * Print Extended Usage
  115.  *
  116.  ---------------------------------------------------------------------------*/
  117.  
  118. void Help(char *fname)
  119. {
  120.     char usage[][85] =
  121.     {
  122.         "  -h or -? to obtain this help screen\n",
  123.         "  @LISTFILE for list file of input file names.  A list file is in the form",
  124.         "     of a response file (ie. a list of files seperated by some delimiter).",
  125.         "     The allowed delimiters for file seperation are '+', ',', ';' and normal",
  126.         "     whitespace.  This file allows commented lines by preceding any comment",
  127.         "     with a pound sign (#).  A comment is from the '#' to the end of the",
  128.         "     line and may start after any whitespace character\n",
  129.         "  -x{EXCLUDEFILE|@LISTFILE} excludes the files specified by EXCLUDEFILE",
  130.         "     or exclude all files listed in LISTFILE.\n",
  131.         "  -tTAGFILE to output to a (possibly existing) tag file and will result in",
  132.         "     previous tags for input files being removed from the output file.",
  133.         "     This tagfile is assumed to be in one of this utilities output formats.",
  134.         "     if -m or -s are used this switch is ignored (all output is to stdout).\n",
  135.         "  -lLOGFILE for output to a log file in a LISTFILE format suitable as input.",
  136.         "    behavior regarding existing files is determined by the case of the switch.",
  137.         "    -l  creates and outputs to a file overwriting any currently existing file",
  138.         "    -L  appends all output to the logfile if there is an already existing file\n",
  139.         "  -o[options] for output format to stdout or the tag file if -t switch is used",
  140.         "     e  Epsilon >= V6.0  ( tokenString \\t fileName \\t characterOffset \\t line )",
  141.         "     5  Epsilon <= V5.03 ( tokenString;fileName;characterOffset )",
  142.         "     g  GNU tag          ( tokenString \\t fileName \\t /$line^/ )",
  143.         "     s  Space-Delimited  ( tokenString fileName lineNumber )",
  144.         "     m  MicroSoft Error  ( tokenString fileName(lineNumber) )\n",
  145.         "  -a[options] to specify assembly tagging and to detail the token types.",
  146.         "     Default tagging is -afdlmsu (80x86 assembly using MASM/TASM syntax)",
  147.         "     f  procedure labels       ( token proc )( proc token )",
  148.         "     d  definition labels      ( token equ const )( token db declaration )",
  149.         "     l  local labels           ( token label )( label token )( token: )",
  150.         "     m  macro labels           ( token macro )( macro token )",
  151.         "     s  struc labels           ( token struc )( struc token )",
  152.         "     u  union labels           ( token union )( union token )\n",
  153.         "  -c[options] to specify C tagging and to detail the token types. Default",
  154.         "     tagging options are -cdmstekuvcfpxi (standard ANSI 2.0 C/C++). Note that",
  155.         "     use of the -cx and the -ci switch are modifiers and will only be effective",
  156.         "     when other options are used (ie. -cpx must be specified to obtain extern",
  157.         "     prototypes, -cx alone yields nothing).  Note that th